package com.ys.controller.web.hr;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bo.vo.W;
import com.ys.config.MenuId;
import com.ys.config.MyConfig;
import com.ys.entity.hr.TbMedicalInsurance;
import com.ys.service.sys.CommonApiService;

@Controller
@RequestMapping("/web/hr/tbMedicalInsurance")
public class WebTbMedicalInsuranceController {

	@Autowired
	private CommonApiService<TbMedicalInsurance> commonApiService;

	/*
	 * 新增
	 */
	@GetMapping("/toAdd")
	public String toAdd(Model model) throws Exception{
		TbMedicalInsurance entity = new TbMedicalInsurance();
		entity.setStatus(1);
		String aa = commonApiService.toAdd(model, entity, MenuId.TB_MedicalInsurance, null, null);
        
        if ("test".equals(MyConfig.getActive()) || "pro".equals(MyConfig.getActive())) {
			return "hr/tbMedicalInsurance/toAdd";
		} else {
			return aa;
		}
	}
	/*
	 * 编辑
	 */
	@GetMapping("/toEdit")
	public String toEdit(Model model, Long id) throws Exception{
		if (id == null){
			return W.error(model, "id不能为空");
		}

		if (new TbMedicalInsurance().setId(id).count() == 0){
			return W.error(model, "该信息不存在!");
		}
		String aa = commonApiService.toEdit(model, id, new TbMedicalInsurance(), MenuId.TB_MedicalInsurance, null, null);
        
        if ("test".equals(MyConfig.getActive()) || "pro".equals(MyConfig.getActive())) {
    		return "hr/tbMedicalInsurance/toEdit";
		} else {
			return aa;
		}
	}
}
